package com.budwk.app.sqfw.models;

import cn.hutool.core.collection.CollectionUtil;
import com.budwk.app.sqfw.dto.PersonnelTagDTO;
import com.budwk.app.util.StrUtil;
import com.budwk.starter.common.openapi.annotation.ApiModel;
import com.budwk.starter.common.openapi.annotation.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author ZY.Wang
 * @since 2023/7/17
 */
@Data
@Accessors(chain = true)
@Table("shequ.sqfw_person_info")
@Comment("人员信息")
@ApiModel(description = "人员信息")
public class PersonInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    @Column
    @Name
    @Comment("编号")
    @ApiModelProperty(description = "ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(els = {@EL("snowflake()")}, nullEffective = true)
    private String id;

    @Column("house_id")
    @Comment("房屋id")
    @ApiModelProperty(description = "房屋id")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String houseId;

    @Column("name")
    @Comment("姓名 (Name)")
    @ApiModelProperty(description = "姓名 (Name)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String name;

    @Column("id_type")
    @Comment("证件类型 (ID Type)")
    @ApiModelProperty(description = "证件类型 (ID Type)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String idType;

    @Column("id_number")
    @Comment("证件号 (身份证等核心主键)")
    @ApiModelProperty(description = "证件号 (身份证等核心主键)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String idNumber;

    @Column("gender")
    @Comment("性别 (Gender)")
    @ApiModelProperty(description = "性别 (Gender)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String gender;

    @Column("age")
    @Comment("年龄 (Age)")
    @ApiModelProperty(description = "年龄 (Age)")
    @ColDefine(type = ColType.INT, width = 50)
    private Integer age;

    @Column("birth_date")
    @Comment("出生日期(常住人口) (Birth Date - Permanent Resident)")
    @ApiModelProperty(description = "出生日期(常住人口) (Birth Date - Permanent Resident)")
    @ColDefine(type = ColType.DATE, width = 50)
    private LocalDate birthDate;

    @Column("marital_status")
    @Comment("婚姻状况(常住人口) (Marital Status - Permanent Resident)")
    @ApiModelProperty(description = "婚姻状况(常住人口) (Marital Status - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String maritalStatus;

    @Column("education")
    @Comment("文化程度(常住人口) (Education Level - Permanent Resident)")
    @ApiModelProperty(description = "文化程度(常住人口) (Education Level - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String education;

    @Column("political_status")
    @Comment("政治面貌(常住人口) (Political Status - Permanent Resident)")
    @ApiModelProperty(description = "政治面貌(常住人口) (Political Status - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 20)
    private String politicalStatus;

    @Column("religion")
    @Comment("宗教信仰(常住人口) (Religion - Permanent Resident)")
    @ApiModelProperty(description = "宗教信仰(常住人口) (Religion - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String religion;

    @Column("address")
    @Comment("居住地址（全内容） (Residential Address - Full Content)")
    @ApiModelProperty(description = "居住地址（全内容） (Residential Address - Full Content)")
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String address;

    @Column("phone")
    @Comment("联系电话（关联键） (Phone Number - Foreign Key)")
    @ApiModelProperty(description = "联系电话（关联键） (Phone Number - Foreign Key)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String phone;

    @Column("health_status")
    @Comment("健康状况 (Health Status)")
    @ApiModelProperty(description = "健康状况 (Health Status)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String healthStatus;

    @Column("employer")
    @Comment("工作单位 (Employer)")
    @ApiModelProperty(description = "工作单位 (Employer)")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String employer;

    @Column("province")
    @Comment("省份 (居住地)")
    @ApiModelProperty(description = "省份 (居住地)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String province;

    @Column("city")
    @Comment("市 (居住地)")
    @ApiModelProperty(description = "市 (居住地)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String city;

    @Column("district")
    @Comment("区 (居住地)")
    @ApiModelProperty(description = "区 (居住地)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String district;

    @Column("county")
    @Comment("街道 (居住地)")
    @ApiModelProperty(description = "街道 (居住地)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String county;

    @Column("community")
    @Comment("社区 (居住地)")
    @ApiModelProperty(description = "社区 (居住地)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String community;

    @Column("courtyard")
    @Comment("院子名称 (Courtyard)")
    @ApiModelProperty(description = "院子名称 (Courtyard)")
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String courtyard;

    @Column("house_number")
    @Comment("房屋编号 (House Number)")
    @ApiModelProperty(description = "房屋编号 (House Number)")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String houseNumber;

    @Column("grid")
    @Comment("网格 (Grid)")
    @ApiModelProperty(description = "网格 (Grid)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String grid;

    @Column("house_hold_number")
    @Comment("户号 (Household Number)")
    @ApiModelProperty(description = "户号 (Household Number)")
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String houseHoldNumber;

    @Column("building")
    @Comment("楼栋 (Building)")
    @ApiModelProperty(description = "楼栋 (Building)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String building;

    @Column("special_mark")
    @Comment("特殊标志 (Special Mark)")
    @ApiModelProperty(description = "特殊标志 (Special Mark)")
    @ColDefine(type = ColType.PSQL_JSON, width = 200)
    private List<PersonnelTagDTO> specialMark;

    @Column("unit_id")
    @Comment("单位id (Unit ID)")
    @ApiModelProperty(description = "单位id (Unit ID)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String unitId;

    @Column("unit_name")
    @Comment("单位名称 (Unit Name)")
    @ApiModelProperty(description = "单位名称 (Unit Name)")
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String unitName;

    @Column("latest_status")
    @Comment("状态 (Latest Status)")
    @ApiModelProperty(description = "状态(搬离 正常 死亡)")
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String latestStatus;

    @Column("detail_address")
    @Comment("详细地址 (主管行政区划（完整）)")
    @ApiModelProperty(description = "详细地址 (主管行政区划（完整）)")
    @ColDefine(type = ColType.VARCHAR, width = 300)
    private String detailAddress;

    @Column("strengths")
    @Comment("特长 (Strengths)")
    @ApiModelProperty(description = "特长 (Strengths)")
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String strengths;

    @Column("emergency_phone")
    @Comment("紧急联系电话 (Emergency Phone)")
    @ApiModelProperty(description = "紧急联系电话 (Emergency Phone)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String emergencyPhone;

    @Column("emergency_people")
    @Comment("紧急联系人")
    @ApiModelProperty(description = "紧急联系人")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String emergencyPeople;

    @Column("special_mark_ids")
    @Comment("特殊人员类型 (Special Mark IDs)")
    @ApiModelProperty(description = "特殊人员类型 (Special Mark IDs)")
    @ColDefine(type = ColType.VARCHAR, width = 500)
    private String specialMarkIds;

    @Column("current_location")
    @Comment("现在地(三关人员) (Current Location - Three Types of Personnel)")
    @ApiModelProperty(description = "现在地(三关人员) (Current Location - Three Types of Personnel)")
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String currentLocation;

    @Column("welfare_status")
    @Comment("是否有低保(三关人员) (Welfare Status - Three Types of Personnel)")
    @ApiModelProperty(description = "是否有低保(三关人员) (Welfare Status - Three Types of Personnel)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String welfareStatus;

    @Column("reg_address")
    @Comment("户籍地址【常住人口】 (Registered Address - Permanent Resident)")
    @ApiModelProperty(description = "户籍地址【常住人口】 (Registered Address - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 300)
    private String regAddress;

    @Column("is_registered")
    @Comment("是否户籍(常住人口) (Is Registered - Permanent Resident)")
    @ApiModelProperty(description = "是否户籍(常住人口) (Is Registered - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String isRegistered;

    @Column("reg_province")
    @Comment("户籍省份 (主管行政区划)")
    @ApiModelProperty(description = "户籍省份 (主管行政区划)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String regProvince;

    @Column("reg_city")
    @Comment("户籍市 (主管行政区划)")
    @ApiModelProperty(description = "户籍市 (主管行政区划)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String regCity;

    @Column("reg_district")
    @Comment("户籍区 (主管行政区划)户籍区 (主管行政区划)")
    @ApiModelProperty(description = "户籍区 (主管行政区划)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String regDistrict;

    @Column("reg_county")
    @Comment("户籍街道 (主管行政区划)")
    @ApiModelProperty(description = "户籍街道 (主管行政区划)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String regCounty;

    @Column("reg_community")
    @Comment("户籍社区 (主管行政区划)")
    @ApiModelProperty(description = "户籍社区 (主管行政区划)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String regCommunity;

    @Column("reg_grid")
    @Comment("户籍网格(常住人口) (Registered Grid - Permanent Resident)")
    @ApiModelProperty(description = "户籍网格(常住人口) (Registered Grid - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String regGrid;

    @Column("reg_number")
    @Comment("户号(常住人口) (Household Number - Permanent Resident)")
    @ApiModelProperty(description = "户号(常住人口) (Household Number - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String regNumber;

    @Column("reg_type")
    @Comment("户口类型(常住人口) (Household Type - Permanent Resident)")
    @ApiModelProperty(description = "户口类型(常住人口) (Household Type - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String regType;

    @Column("relation_to_head")
    @Comment("与户主关系(常住人口) (Relation to Household Head - Permanent Resident)")
    @ApiModelProperty(description = "与户主关系(常住人口) (Relation to Household Head - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String relationToHead;

    @Column("head_name")
    @Comment("户主姓名(常住人口) (Household Head Name - Permanent Resident)")
    @ApiModelProperty(description = "户主姓名(常住人口) (Household Head Name - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String headName;

    @Column("head_id_number")
    @Comment("户主证件号(常住人口) (Household Head ID Number - Permanent Resident)")
    @ApiModelProperty(description = "户主证件号(常住人口) (Household Head ID Number - Permanent Resident)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String headIdNumber;

    @Column("admin_code")
    @Comment("行政区划编码 (Administrative Division Code)")
    @ApiModelProperty(description = "行政区划编码 (Administrative Division Code)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String adminCode;

    @Column("create_date")
    @Comment("添加时间 (Create Date)")
    @ApiModelProperty(description = "添加时间 (Create Date)")
    @ColDefine(type = ColType.DATETIME, width = 50)
    private LocalDateTime createDate;

    @Column("update_date")
    @Comment("修改时间 (Update Date)")
    @ApiModelProperty(description = "修改时间 (Update Date)")
    @ColDefine(type = ColType.DATETIME, width = 50)
    private LocalDateTime updateDate;

    @Column("create_by")
    @Comment("创建者 (Created By)")
    @ApiModelProperty(description = "创建者 (Created By)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String createBy;

    @Column("update_by")
    @Comment("更新者 (Updated By)")
    @ApiModelProperty(description = "更新者 (Updated By)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String updateBy;

    @Column("remark")
    @Comment("备注 (Remark)")
    @ApiModelProperty(description = "备注 (Remark)")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String remark;

    @Column("business_type")
    @Comment("数据来源")
    @ApiModelProperty(description = "数据来源")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String businessType;

    @Column("party_membership_time")
    @Comment("入党时间")
    @ApiModelProperty(description = "入党时间")
    @ColDefine(type = ColType.DATETIME, width = 50)
    private LocalDateTime partyMembershipTime;

    @Column("nation")
    @Comment("民族")
    @ApiModelProperty(description = "民族")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String nation;

    @Column("summary_id")
    @Comment("summary_id")
    @ApiModelProperty(description = "summary_id")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String summaryId;

    @Column("household_id")
    @Comment("户ID")
    @ApiModelProperty(description = "户ID")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String householdId;

    @Column("people_code")
    @Comment("人员编号")
    @ApiModelProperty(description = "people_code")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String peopleCode;

    @Column("household_head_relation")
    @Comment("与户主关系")
    @ApiModelProperty(description = "household_head_relation")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String householdHeadRelation;

    @Column("check_update")
    @Comment("检查时间，格式yyyy-mm,此字段用于当季度是否检查过")
    @ApiModelProperty(description = "检查时间，格式yyyy-mm")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String checkUpdate;

    @Column("minLiv_allow")
    @Comment("最低生活保障金")
    @ApiModelProperty(description = "最低生活保障金")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal minLivAllow;

    @Column("asst_fund")
    @Comment("特困人员救助供养金")
    @ApiModelProperty(description = "特困人员救助供养金")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal asstFund;

    @Column("pension")
    @Comment("养老金或退休金")
    @ApiModelProperty(description = "养老金或退休金")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal pension;

    @Column("family_plan_allowance")
    @Comment("计划生育金")
    @ApiModelProperty(description = "计划生育金")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal familyPlanAllowance;

    @Column("ecoComp")
    @Comment("生态补偿金")
    @ApiModelProperty(description = "生态补偿金")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal ecoComp;

    @Column("property_bonus")
    @Comment("产业奖金")
    @ApiModelProperty(description = "产业奖金")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal propertyBonus;

    @Column("work_bonus")
    @Comment("就业奖金")
    @ApiModelProperty(description = "就业奖金")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal workBonus;

    @Column("disability_allowance")
    @Comment("残疾人补贴")
    @ApiModelProperty(description = "残疾人补贴")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal disabilityAllowance;

    @Column("farm_allowance")
    @Comment("农业直接补贴")
    @ApiModelProperty(description = "农业直接补贴")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal farmAllowance;

    @Column("support_income")
    @Comment("赡养收入")
    @ApiModelProperty(description = "赡养收入")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal supportIncome;

    @Column("other_subsidies")
    @Comment("其他收入")
    @ApiModelProperty(description = "其他收入")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private BigDecimal otherSubsidies;

    @Column("param_data")
    @Comment("其他参数")
    @ApiModelProperty(description = "其他参数")
    @ColDefine(type = ColType.PSQL_JSON)
    private String paramData;

    private String checkStatus;

    @Column("delete_reason")
    @Comment("删除原因")
    @ApiModelProperty(description = "删除原因")
    @ColDefine(type = ColType.VARCHAR, width = 300)
    private String deleteReason;

    @Column("deleted")
    @Comment("是否删除")
    @ApiModelProperty(description = "是否删除")
    @ColDefine(type = ColType.BOOLEAN, width = 50)
    private boolean deleted;

    @Column("longitude")
    @Comment("经度")
    @ApiModelProperty(description = "经度")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String longitude;

    @Column("latitude")
    @Comment("纬度")
    @ApiModelProperty(description = "纬度")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String latitude;

    public void setSpecialMark(List<PersonnelTagDTO> specialMark) {
        if (CollectionUtil.isNotEmpty(specialMark)) {
            List<PersonnelTagDTO> personnelTagDTOS = StrUtil.toListByJson(PersonnelTagDTO.class, specialMark.get(0));
            if (personnelTagDTOS != null) {
                this.specialMark = personnelTagDTOS;
                return;
            }
        }
        this.specialMark = specialMark;
    }
}
